package icu.zhhll.lp;

import org.apache.commons.lang3.StringUtils;

/**
 * LP参数
 *
 * @author zh
 * @date 2023/9/18 10:48
 */
public class LpParam {
    // 权重  默认为1
    private double weight = 1;
    // 变量名
    private String varName;
    // 变量索引  varIndex和varName必须有一个
    private Integer varIndex;

    public double getWeight() {
        return weight;
    }

    public LpParam setWeight(double weight) {
        this.weight = weight;
        return this;
    }

    public String getVarName() {
        return varName;
    }

    public LpParam setVarName(String varName) {
        if (varIndex != null) {
            throw new LpParamException("变量索引和变量名称只需设置一个");
        }
        this.varName = varName;
        return this;
    }

    public Integer getVarIndex() {
        return varIndex;
    }

    public LpParam setVarIndex(Integer varIndex) {
        if (StringUtils.isNotBlank(varName)) {
            throw new LpParamException("变量索引和变量名称只需设置一个");
        }
        this.varIndex = varIndex;
        return this;
    }
}
